<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      list-style: none;
    }
    html{
      background-color: black;
    }
    a{
      display: block;
      height: 40px;
      width: 150px;
      line-height: 40px;
      color:#fff;
      text-decoration: none;
      background-color: gold;
      border-radius: 10px;
      text-align: center;
      margin: 20px auto;
    }
    ul{
      width: 500px;
      margin: 0 auto;
    }
    li{
      width: 100px;
      height: 100px;
      float: left;
    }
    img{
      width: 100%;
      height: 100%;
      transition: all 1s linear;
    }
    .change{
      transform: scale(1.5,1.5);
    }
  </style>
</head>
<body>
 <a href="javaScript:void(0)">创建英雄列表</a>
 <script>
   var data = [
    {imgsrc:"img/01.jpg",imgtitle:"司马懿1"},
		{imgsrc:"img/02.jpg",imgtitle:"司马懿2"},
		{imgsrc:"img/03.jpg",imgtitle:"司马懿3"},
		{imgsrc:"img/04.jpg",imgtitle:"司马懿4"},
		{imgsrc:"img/05.jpg",imgtitle:"司马懿5"},
		{imgsrc:"img/06.jpg",imgtitle:"司马懿6"},
		{imgsrc:"img/07.jpg",imgtitle:"司马懿7"},
		{imgsrc:"img/08.jpg",imgtitle:"司马懿8"},
		{imgsrc:"img/09.jpg",imgtitle:"司马懿9"},
		{imgsrc:"img/10.jpg",imgtitle:"司马懿10"},
		{imgsrc:"img/11.jpg",imgtitle:"司马懿11"},
		{imgsrc:"img/12.jpg",imgtitle:"司马懿11"},
		{imgsrc:"img/13.jpg",imgtitle:"司马懿11"},
		{imgsrc:"img/14.jpg",imgtitle:"司马懿11"},
		{imgsrc:"img/15.jpg",imgtitle:"司马懿11"},
		{imgsrc:"img/16.jpg",imgtitle:"司马懿11"}
  ];
  //创建元素
  var abtn = document.querySelector('a');
  var ul;
  var li;
  var img;
  var body = document.querySelector('body');
  abtn.onclick = function(){
    if(document.querySelector('ul')){
      return;
    }
    ul = document.createElement('ul');
    //根据数据创建li
    for(var i = 0; i < data.length; i++){
      li = document.createElement('li');
      img = document.createElement('img');
      img.src = data[i].imgsrc;
      img.title = data[i].imgtitle;
      //设置鼠标进入时候的事件
      img.onmouseenter = function(){
        this.className = 'change';
      }
      //设置鼠标离开事件
      img.onmouseleave = function(){
        this.className = '';
      }

      li.appendChild(img);
      ul.appendChild(li);
    }
    body.appendChild(ul);
   
  }
 </script>
</body>
</html>